﻿

Shader "Unlit/TestTerrain"
{
    Properties
    {
        //_MainTex ("Texture", 2D) = "white" {}
		[NoScaleOffset]_MainTexArray("图层图集", 2DArray) = "" {}
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 100

        Pass
        {
			Tags {"LightMode" = "ForwardBase"}
			
            CGPROGRAM
			#define FORWARD_BASE_PASS
			
			#pragma multi_compile  LIGHTPROBE_SH
			#pragma multi_compile  DIRECTIONAL

		 

			#pragma multi_compile  _ LIGHTMAP_SHADOW_MIXING

			#pragma multi_compile  _ LIGHTMAP_OFF LIGHTMAP_ON   
			#pragma multi_compile  _ SHADOWS_SCREEN 
			#pragma multi_compile  _ SHADOWS_SHADOWMASK
			#pragma multi_compile   _NORMAL_MAP _ 
			#pragma multi_compile   _SPEC_ENABLE _ 
			#pragma multi_compile   _WATER _ 
			#pragma multi_compile _ _MAP_FOG
			#pragma multi_compile _ _MAP_LAND
			#pragma multi_compile _  _FLOWMAP

//#define OLD 1
#ifdef OLD

				 

            #pragma vertex myvert
            #pragma fragment myfrag
#else
			#pragma vertex myvert1
			#pragma fragment myfrag1
#endif
            
			
			

            #include "UnityCG.cginc"
			#include "terrain_phone.cginc"
             

            struct myv2f
            {
                float2 uv : TEXCOORD0;
 
                float4 vertex : SV_POSITION;
            };

        

            myv2f myvert (appdata_full v)
            {
                myv2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.uv = v.texcoord;
 
                return o;
            }
			//UNITY_DECLARE_TEX2DARRAY(_MainTexArray);
            fixed4 myfrag (myv2f i) : SV_Target
            {
                // sample the texture
                //fixed4 col = tex2D(_MainTex, i.uv);
				fixed4 col = UNITY_SAMPLE_TEX2DARRAY(_MainTexArray, half3(i.uv*12, 0));
                // apply fog
                //UNITY_APPLY_FOG(i.fogCoord, col);
                return col;
            }

			v2f myvert1(appdata_full v)
			{
				v2f o = (v2f)0;
				o.pos = UnityObjectToClipPos(v.vertex);
				o.uv = v.texcoord;

				return o;
			}
			//UNITY_DECLARE_TEX2DARRAY(_MainTexArray);
			half4 myfrag1(v2f i) : SV_Target
			{
				// sample the texture
				//fixed4 col = tex2D(_MainTex, i.uv);
				fixed4 col = UNITY_SAMPLE_TEX2DARRAY(_MainTexArray, half3(i.uv * 12, 0));
			 
			return col;
			}
            ENDCG
        }

		UsePass "Mobile/VertexLit/ShadowCaster"
		UsePass "Hidden/Terrain PhoneMeta/Meta"

    }
}
